#!/usr/bin/env bash

if [ $# -ne 1 ]; then
  echo "no version number specified"
  exit 1;
fi


DATE=$(date +"%d/%m/%y")
VERSION=$1
DATE_ESC=$(echo $DATE | sed 's/\//\\\//g')
sed -i -r "s/SetInfoVersion(.*?);/SetInfoVersion('$VERSION');/g" languages/*.php
shopt -s globstar

sed -i -r "s/PROJECT_NUMBER.*/PROJECT_NUMBER = $VERSION/g" Doxyfile
sed -i -r "1 s/^version svn.*/Version $VERSION ($DATE_ESC)/gi" ChangeLog
sed -i -r "s/(\LUMINOUS_VERSION\s*=).*/\\1 '$VERSION';/g" src/luminous.php
sed -i -r "s/(var\s+luminous_version\s*=).*/\\1 '$VERSION';/;
  s/(var\s+luminous_date\s*=).*/\\1 '$DATE_ESC';/" client/luminous.js
sed -i -r "s/([@\\]since\s+)svn/\\1 $VERSION/gi" src/**/*.php
sed -i -r "1 s/^(Luminous Version).*/\\1 $VERSION/gi" README
